﻿using System;

namespace FluentResourceMapping
{
    public class FluentlyConfiguration
    {
        private Action<MappingConfiguration> mappingBuilder;
        private readonly ResourceMappingModel resourceMappingModel;

        public FluentlyConfiguration()
        {
            resourceMappingModel = new ResourceMappingModel();
        }

        public FluentlyConfiguration(ResourceMappingModel resourceMappingModel)
        {
            this.resourceMappingModel = resourceMappingModel;
        }

        public FluentlyConfiguration Mappings(Action<MappingConfiguration> mappings)
        {
            this.mappingBuilder = mappings;
            return this;
        }

        public ResourceMappingModel BuildResourceMappingModel()
        {
            MappingConfiguration mappingConfig = new MappingConfiguration();

            if (mappingBuilder != null)
                mappingBuilder(mappingConfig);

            mappingConfig.Apply(resourceMappingModel);

            return resourceMappingModel;
        }
    }
}